/*********************************************************************************************************
* Author : Michael Henry Pantaleon
* Email  : michaelhenry119@yahoo.com.ph
*          admin@michaelhenrypantaleon.com
* Website : www.michaelhenrypantaleon.com
* Description : My Image Preloader
* Create Date : April 05 2011
* Modified Date : May 12 2011
* version : 1.01
* Package : myImagePreloader
* Requirements :
* --------  latest jquery
* 
* OPTIONS :
*    Events : onLoaded, onFinished, onError
*    Properties : allowFadeIn, fadeInTimeOut
*
* Copyright (C) 2011  Michael Henry Pantaleon
* 
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* 
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
* 
* You should have received a copy of the GNU General Public License
* along with this program.  If not, see <http://www.gnu.org/licenses/>.
********************************************************************************************************
*/
(function(a){a.fn.myImagePreloader=function(h){var f={allowFadeIn:false,fadeInTimeOut:2000,onLoaded:null,onFinished:null,onError:null};var h=a.extend(f,h);var d=a(this);var e=d.length;for(var c=0;c<e;c++){var b=d.eq(c);g(b,b.attr("imageUrl"))}function g(i,k){var j=new Image();if(h.allowFadeIn){a(j).attr("src",k).attr("width",i.width()).attr("height",i.height()).load(function(){i.removeClass("img-preloader").append(this);if(a.isFunction(h.onLoaded)){h.onLoaded.apply()}}).fadeIn(h.fadeInTimeOut,function(){});a(j).error(function(){i.removeClass("img-preloader").addClass("img-error").fadeIn(h.fadeInTimeOut,function(){});if(a.isFunction(h.onError)){h.onError.apply()}})}else{a(j).attr("src",k).attr("width",i.width()).attr("height",i.height()).load(function(){i.removeClass("img-preloader").append(this);if(a.isFunction(h.onLoaded)){h.onLoaded.apply()}});a(j).error(function(){i.removeClass("img-preloader").addClass("img-error");if(a.isFunction(h.onError)){h.onError.apply()}})}}if(a.isFunction(h.onFinished)){h.onFinished.apply()}}})(jQuery);